/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.vasthu.core.service;

import com.vasthu.api.dao.StockDAO;
import com.vasthu.api.domain.Stock;
import com.vasthu.api.service.StockManagerService;
import com.vasthu.core.service.StockManagerServiceImpl;
import com.vasthu.core.dao.StockDAOImpl;
import com.vasthu.gui.VstTableItemSelectable;
import com.vasthu.utility.VstDBManager;
import java.sql.*;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author moremada
 */
public class StockManagerServiceImpl implements StockManagerService {

    StockDAO stockDAO;

    public StockManagerServiceImpl() {
        stockDAO = new StockDAOImpl();
    }

    @Override
    public boolean insertStock(Stock stock) {
        if (stock == null) {
            return false;
        }
        boolean ok = stockDAO.insertStock(stock);
        return ok;
    }

    @Override
    public Stock getStockById(long stockId) {
        Stock stock = null;
        stock = stockDAO.getStockById(stockId);
        return stock;
    }

    @Override
    public boolean deleteStockById(long stockId) {
        boolean ok = stockDAO.deleteStockById(stockId);
        return ok;
    }

    @Override
    public List<String> getAllStockNames() {
        return null;
    }

    @Override
    public List<VstTableItemSelectable> getAllStockedItemsForTable() {
        List<Stock> stockList = new ArrayList<Stock>();
        List<VstTableItemSelectable> dataList = new ArrayList<VstTableItemSelectable>();
        stockList = stockDAO.getAllStockItems();
        for (Stock stock : stockList) {
            dataList.add(stock);
        }
        return dataList;
    }
}
